
import 'dart:collection';
import 'dart:typed_data';

import 'package:flutter_my_web/dao/DataManagerDB.dart';


class DataManagerImageBean {

  String? millisecondTimeStr;
  String? imageId;
  String? netPath; //网络图片路径
  String? imagePath; //本地图片路径
  String? imageName; //图片名称
  String? fileBase64Data;//base64的数据
  Uint8List? bytes;//base64的数据
  bool? isSelect = false;//是否有选择
  bool isShowSelect = false;//是否有选择

  DataManagerImageBean();

  DataManagerImageBean.fromSql(LinkedHashMap<String, dynamic> jsonStr) {
    millisecondTimeStr=jsonStr[DataManagerDB.millisecondTimeStr];
    netPath = jsonStr[DataManagerDB.netPath];
    imagePath = jsonStr[DataManagerDB.imagePath];
    imageName = jsonStr[DataManagerDB.imageName];
    imageId = jsonStr[DataManagerDB.imageId];
  }
  Map<String, dynamic> saveSql() {
    final LinkedHashMap<String, dynamic> data = new LinkedHashMap<String, dynamic>();
    data[DataManagerDB.millisecondTimeStr] = this.millisecondTimeStr;
    data[DataManagerDB.netPath] = this.netPath;
    data[DataManagerDB.imagePath] = this.imagePath;
    data[DataManagerDB.imageName] = this.imageName;
    data[DataManagerDB.imageId] = this.imageId;
    return data;
  }
  Map<String, dynamic> toJson() {
    final LinkedHashMap<String, dynamic> data = new LinkedHashMap<String, dynamic>();
    data[DataManagerDB.millisecondTimeStr] = this.millisecondTimeStr;
    data[DataManagerDB.netPath] = this.netPath;
    data[DataManagerDB.imagePath] = this.imagePath;
    data[DataManagerDB.imageName] = this.imageName;
    data[DataManagerDB.imageId] = this.imageId;
    data["fileBase64"] = this.fileBase64Data;
    return data;
  }


  @override
  String toString() {
    return 'DataManagerImageBean{millisecondTimeStr: $millisecondTimeStr, imageId: $imageId, netPath: $netPath, imagePath: $imagePath, imageName: $imageName, isSelect: $isSelect, isShowSelect: $isShowSelect}';
  }

  String getTime(){
    try{
      var millisecond = int.parse(millisecondTimeStr!);
      var dateTime = new DateTime.fromMillisecondsSinceEpoch(millisecond);
      return "${dateTime.year}-${dateTime.month}-${dateTime.day}";
    }catch(e){
      print(e.toString());
      return "";
    }
  }


}
